<template>
	<view class="content">
		<view class="title">
			<uni-icons type="left" size="30" color="white" @click="huitui"></uni-icons>
			<view>发布</view>
			<button @click="add_video">上传</button>
		</view>
		<view class="video_title">
			<textarea v-model="video_desc" name="" id="" cols="30" rows="10" placeholder="请输入文案"></textarea>
			<video :src="video"></video>
		</view>
		<wd-select-picker label="谁可以看" v-model="who_see" :columns="columns" type="radio"></wd-select-picker>
		<wd-select-picker label="谁可以评论" v-model="who_pinlun" :columns="columns" type="radio"></wd-select-picker>
		<!-- 		<wd-select-picker label="地区" v-model="video_address" :columns="columns1" type="radio"></wd-select-picker> -->
		<wd-select-picker label="谁可以看" v-model="video_address" :columns="columns1" type="radio"></wd-select-picker>

		<wd-toast />
	</view>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { post_Video } from '../../../api/api';
import { useToast } from '@/uni_modules/wot-design-uni';

const toast = useToast();
const props = defineProps<{ video: string }>();
const video = ref('');
video.value = props.video;
const video_desc = ref('');
const video_address = ref('');
const who_see = ref('');
const who_pinlun = ref('');
const columns = ref<Record<string, any>>([
	{
		value: '101',
		label: '所有人'
	},
	{
		value: '102',
		label: '仅关注的人'
	},
	{
		value: '103',
		label: '私密'
	}
]);
const columns1 = ref<Record<string, any>>([
	{
		value: '石家庄',
		label: '石家庄市'
	},
	{
		value: '唐山市',
		label: '唐山市'
	},
	{
		value: '秦皇岛',
		label: '秦皇岛市'
	},
	{
		value: '邢台市',
		label: '邢台市'
	},
	{
		value: '保定市',
		label: '保定市'
	},
	{
		value: '张家口市',
		label: '张家口市'
	},
	{
		value: '承德市',
		label: '承德市'
	},
	{
		value: '沧州市',
		label: '沧州市'
	},
	{
		value: '廊坊市',
		label: '廊坊市'
	},
	{
		value: '衡水市',
		label: '衡水市'
	}
]);
const add_video = async () => {
	let data = await post_Video({
		src: video.value,
		video_desc: video_desc.value,
		video_time: new Date(),
		video_address: video_address.value
	});
	console.log(data);
	if (data.code == 200) {
		toast.success({
			iconClass: 'star',
			msg: '发布成功，请等待审核'
		});
		let a = setTimeout(() => {
			uni.redirectTo({
				url: '/pages/Home/Home'
			});
			clearTimeout(a);
		}, 2000);
	}
};
const huitui = () => {
	uni.navigateBack({
		delta: 2
	});
};
</script>

<style scoped lang="scss">
.content {
	width: 100vw;
	height: 100vh;
	background-color: black;
	overflow: hidden;
	.title {
		width: 100%;
		height: 50px;
		background-color: rgb(25, 25, 25);
		color: white;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-top: 2.5rem;
		padding-bottom: 2.5rem;
		padding-right: 1rem;
		padding-left: 1rem;

		view {
			font-size: 20px;
		}
		button {
			margin: 0;
			border-radius: 25px;
			background-color: yellow;
		}
	}
	.video_title {
		display: flex;
		background-color: rgb(25, 25, 25);
		align-items: center;
		margin-bottom: 1rem;
		video {
			width: 7rem;
			height: 5rem;
		}
		textarea {
			color: white;
		}
	}
	.video_item {
		width: 100vw;
		color: white;
		background-color: rgb(25, 25, 25);
		font-size: 16px;
		padding: 1rem;
	}
}
</style>
